---

- name: backup database
  cron:
    name: "backup database"
    user: faf
    job: "( pg_dump -Fc faf > /srv/faf/db-backup/backup-$(date '+\\%F').dump ) >> /var/log/faf/db_backup.log 2>&1"
    special_time: daily
    state: present

- name: match unknown packages
  cron:
    name: "match unknown packages"
    user: faf
    job: "faf match-unknown-packages -d >> /var/log/faf/match-unknown-packages.log 2>&1"
    special_time: daily
    state: present

- name: pull releases, components and associates
  cron:
    name: "cron for {{ item.what }} {{ item.distro }}"
    user: faf
    job: "faf {{ item.what }} -o {{ item.distro }} -d >> /var/log/faf/{{ item.what }}-{{ item.distro }}.log 2>&1"
    special_time: daily
    state: present
  when: not devel
  with_items:
    - { what: "pull-releases", distro: "fedora" }
    - { what: "pull-components", distro: "fedora" }
    - { what: "find-components", distro: "fedora" }
    - { what: "pull-releases", distro: "centos" }
    - { what: "pull-components", distro: "centos" }
    - { what: "find-components", distro: "centos" }

- name: pull associates
  cron:
    name: "cron for pull associates for f{{ item }}"
    user: faf
    job: "faf pull-associates -o fedora --opsys-release {{ item }} >> /var/log/faf/pull-associates-f{{ item }}.log 2>&1"
    special_time: monthly
    state: present
  when: not devel
  with_items:
    - "25"
    - "26"
    - "27"

- name: remove obsolete pull associates
  cron:
    name: "cron for pull associates for f{{ item }}"
    user: faf
    job: "faf pull-associates -o fedora --opsys-release {{ item }} >> /var/log/faf/pull-associates-f{{ item }}.log 2>&1"
    special_time: monthly
    state: absent
  when: not devel
  with_items:
    - "24"

- name: koops_to_xorg.py
  cron:
    name: "koops_to_xorg.py"
    user: faf
    job: "/etc/faf/koops_to_xorg.py >> /var/log/faf/koops-to-xorg.log"
    special_time: daily
    state: present
  when: not devel

- name: probable fixes
  cron:
    name: "cron for probable fixes for f{{ item }}"
    user: faf
    job: "faf mark-probably-fixed -o fedora --opsys-release {{ item }} >> /var/log/faf/mark-probably-fixed-f{{ item }}.log 2>&1"
    special_time: daily
    state: present
  when: not devel
  with_items:
    - "25"
    - "26"
    - "27"

- name: remove obsolete probable fixes
  cron:
    name: "cron for probable fixes for f{{ item }}"
    user: faf
    job: "faf mark-probably-fixed -o fedora --opsys-release {{ item }} >> /var/log/faf/mark-probably-fixed-f{{ item }}.log 2>&1"
    special_time: daily
    state: absent
  when: not devel
  with_items:
    - "24"

- name: update BZ bugs fedora
  cron:
    name: "cron for update BZ bugs fedora"
    user: faf
    job: "faf update-bugs -db fedora-bugzilla >> /var/log/faf/update-bugs.log 2>&1"
    special_time: daily
    state: present
  when: not devel

- name: update BZ bugs centos
  cron:
    name: "cron for update BZ bugs centos"
    user: faf
    job: "faf update-bugs -db centos-mantisbt >> /var/log/faf/update-bugs-centos.log 2>&1"
    special_time: daily
    state: present
  when: not devel

- name: attach BZ bugs centos
  cron:
    name: "cron for attach BZ bugs centos"
    user: faf
    job: "faf update-bugs -db centos-mantisbt >> /var/log/faf/update-bugs-centos.log 2>&1"
    special_time: daily
    state: present
  when: not devel


